package com.xbongbong.saas.script.tempenum;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.pro.enums.AmountFlagEnum;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.pro.enums.SummaryTypeEnum;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.ReimbursementFormEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import lombok.Getter;

/**
 *
 * 创建时间 2020/3/18 2:34 PM
 * 修改时间 2020/3/18 2:34 PM
 * @author chy
 */
@Getter
public enum TempReimbursementFormEnum {
    //模板设计展示字段
    OPEN_APP_ID(ReimbursementFormEnum.OPEN_APP_ID),
    FORM_TYPE(ReimbursementFormEnum.FORM_TYPE),
    FORM_SUB_TYPE(ReimbursementFormEnum.FORM_SUB_TYPE),
    FORM_DATA_CODE(ReimbursementFormEnum.FORM_DATA_CODE),
    REFERENCE_TYPE(ReimbursementFormEnum.REFERENCE_TYPE),
    FORM_NAME(ReimbursementFormEnum.FORM_NAME),
    FORM_USER_CODE(ReimbursementFormEnum.FORM_USER_CODE),
    FORM_USER_NAME(ReimbursementFormEnum.FORM_USER_NAME),
    APPROVED_AMOUNT(ReimbursementFormEnum.APPROVED_AMOUNT),
    ENT_LEGAL_NAME(ReimbursementFormEnum.ENT_LEGAL_NAME),
    DEPARTMENT_ID(ReimbursementFormEnum.DEPARTMENT_ID),
    SUBMIT_TIME(ReimbursementFormEnum.SUBMIT_TIME),
    ADD_TIME(ReimbursementFormEnum.ADD_TIME),
    UPDATE_TIME(ReimbursementFormEnum.UPDATE_TIME),
    CREATOR_ID(ReimbursementFormEnum.CREATOR_ID),
            ;
    /**
     * 报销单枚举
     */
    private ReimbursementFormEnum anEnum;

    TempReimbursementFormEnum(ReimbursementFormEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempReimbursementFormEnum> getAllEnum() {
        List<TempReimbursementFormEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static void initFormDataCode(FieldAttrEntity fieldAttrEntity) {
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.REIMBURSEMENT_FORM.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.REIMBURSEMENT_FORM.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(FORM_DATA_CODE.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setNoRepeat(0);
        fieldAttrEntity.setSerialNumber(InitExplainsHelper.setSerialNumber(SerialNumberEnum.REIMBURSEMENT_FORM_NO));
        fieldAttrEntity.setIsForbidden(0);
    }


    /**
     * 报销人
     *
     * @param fieldAttrEntity
     */
    public static void initFormUserCode(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedText(FORM_USER_NAME.getAnEnum().getAttr());
        fieldAttrEntity.setIsForbidden(0);
    }



    public static void initApprovedAmount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setSummaryFlag(SummaryTypeEnum.SUM.getType());
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
    }

    public static void initSubmitTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setDateType("yyyy-MM-dd HH:mm");
        fieldAttrEntity.setIsForbidden(0);
    }

    public static void initCreatorId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initAddTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initUpdateTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
}
